/* eslint-disable @typescript-eslint/no-floating-promises */
import React, { FC, useEffect, useState } from 'react'
import { useParams } from 'react-router-dom'
import axios from '@/api/request'
import { useDispatch } from 'react-redux'
import style from '@/style/articles/tab/category.module.scss'

const Classify: FC = () => {
  // 路由id & 仓库
  const params = useParams().id
  const dispatch = useDispatch()
  // 数据
  const [data, setData] = useState([])
  useEffect(() => {
    // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
    axios.get(`/wipi/api/article/tag/${params}`).then((res) => {
      setData(res.data[1])
      dispatch({
        type: 'GETDATA',
        payload: res.data[0]
      })
    })
  }, [])
  return (
    <div className={style.category}>
        <p>与 <span>{params}</span> 标签有关的文章</p>
        <p>共搜索到 <span>{data}</span> 篇</p>
    </div>
  )
}

export default Classify
